On XML
__TOC__ * W3C XML Current Status * XML 1.1 Specification * XML 1.0 Specification ** Names and Tokens * Namespaces in XML 1.1 Specification * Namespaces in XML 1.0 Specification * xml:id Version 1.0 * Uniform Resource Identifier (URI) Schemes * XML Tutorial at W3Schools * DTD tutorial * Excerpt from 'The XML Bible' 2nd edition ** XSL Transformations ** XSL Formatting Objects ** XLinks ** XPointers ** Schemas * Concepts ** character reference *** a specific character in the ISO/IEC 10646 character set, for example one not directly accessible from available input devices. *** CharRef ::= '&#' 0-9+ ';' | '&#x' 0-9a-fA-F+ ';' ** entity reference *** the content of a named entity. *** EntityRef ::= '&' Name ';' * Hide (Localize) Versus Expose Namespaces * Make DocumentBuilder.parse ignore DTD references * Attribute-Value Normalization * What does normative and non-normative mean in reference to XML(Jun 21 '11) * XML comments and "--"(May 31 '12) DOM * W3C DOM Technical Reports * DOM Level 3 Core Specification * DOM Level 3 Events Specification ** Event interface ** List of DOM3 Event Types * DOM Reference at MDN ** window.setInterval ** window.setTimeout * DOM Objects and Events at MSDN * DOM configuration parameters * pseudo code for namespace normalization SAX * SAX Java API * SAX Features and Properties XML Pull Parsing * XmlPull project XSLT * XSLT 2.0 Specification * XSLT 2.0 and XQuery 1.0 Serialization Parameters * XSLT 1.1 Specification * XSLT DTD * XSLT Tutorial at W3Schools * XSLT tutorial - basics * Re-using nested XSL templates * How to Transform the Results from Findbugs, Checkstyle and PMD to HTML Report with XSLT 2.0 and Java? XPath XPath 3.0 * XPath 3.0 Specification (W3C Candidate Recommendation) * XQuery and XPath Data Model 3.0 (W3C Candidate Recommendation) * XPath and XQuery Functions and Operators 3.0 (W3C Candidate Recommendation) XPath 2.0 * XPath 2.0 Specification (Second Edition) ** Matching an ItemType and an Item ** Path Expressions ** Unabbreviated Syntax *** node() : all the children of the context node (no attribute nodes are returned, because attributes are not children.) *** *''' : all element children of the context node *** '''text() : all text node children of the context node *** @* : all the attributes of the context node ** Operator Mapping ** [http://www.w3.org/TR/xpath20/#id-sequence-expressions Sequence Expressions] ** For expression (for ~ in expression is in XPath not XQuery !) * XQuery 1.0 and XPath 2.0 Data Model (Second Edition) ** [http://www.w3.org/TR/xpath-datamodel/#dt-sequence Sequence] : an ordered collection of zero or more items. ** [http://www.w3.org/TR/xpath-datamodel/#dt-item Item] : either a node or an atomic value. ** [http://www.w3.org/TR/xpath-datamodel/#Node Node] *** There are seven kinds of Nodes in the data model: document, element, attribute, text, namespace, processing instruction, and comment. * XQuery 1.0 and XPath 2.0 Functions and Operators (Second Edition) ** [http://www.w3.org/TR/xpath-functions/#func-node-name fn:node-name] ** [http://www.w3.org/TR/xpath-functions/#func-name fn:name] ** [http://www.w3.org/TR/xpath-functions/#func-local-name fn:local-name] ** [http://www.w3.org/TR/xpath-functions/#func-data fn:data] ** [http://www.w3.org/TR/xpath-functions/#func-string fn:string] ** [http://www.w3.org/TR/xpath-functions/#func-not fn:not] ** [https://www.w3.org/TR/xpath-functions/#func-matches fn:matches] XPath 1.0 * XPath 1.0 Specification * XPath Syntax and Semantics (at Wikipedia) * XPath Tutorial at W3Schools * XSLT, XPath, and XQuery Functions * XPath tutorial - basics * XPath Function Library of Saxon * Location Steps and Paths in XPath * XPath Expression Syntax * How to retrieve namespaces in XML files using Xpath * How do I use XPath with a default namespace with no prefix?(Mar 26 '10) * XPath 2.0 Gems: Find all duplicate values in a sequence (Part 2) XQuery * XQuery 3.0 Specification (W3C Candidate Recommendation) * XQuery 1.0 Specification ** FLWOR Expressions * XML Query Implementations * XQuery Tutorial at W3Schools * XQuery tutorial - basics * Get Started With XQuery * XQuery on Wikibooks * FunctX XQuery Function Library * An XQJ Tutorial: Introduction to the XQuery API for Java * Blooming FLWOR - An Introduction to the XQuery FLWOR Expression * Saxon XQuery Extensions XML Catalogs * XML Catalogs 1.1 Specification (7 October 2005) * XML Entity and URI Resolvers * How to write an XML catalog file * Apache XML Commons/Resolver/Overview XML Schema * XML Schema Part 0: Primer Second Edition * XML Schema Part 1: Structures Second Edition * XML Schema Part 2: Datatypes Second Edition * W3C XML Schema Definition Language (XSD) 1.1 Part 1: Structures * W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes ** The Assertion Schema Component ** Built-in Datatypes of XSD 2nd Ed. * XML Schema Tutorial at W3Schools * XML Schemas: Best Practices * Develop effective XML documents using structural design patterns * An introduction to XML Schema 1.1 ** Part 1: An overview of the key improvements over XML Schema 1.0 and an in-depth look at datatypes ** Part 2: Co-occurence constraints using XPath 2.0 ** Part 3: Evolve your schema with powerful wildcard support * XML Schema 1.1 Tutorial * What's the best way to version schemas? * XML Schemas: Best Practices ? Versioning * Sample schema - Purchase Order schema from XML Schema specification * Difference between xsd:key and xsd:unique * Enforcing Association Cardinality (June 26, 2002) * XML Schema 1.1 Assertions * How Xerces-J uses an XPath 2.0 engine for XML Schema 1.1 assertions and type alternatives? * Composition versus Subclassing * Creating a Unique Constrant with an XSD * XML schema unique validation is not working * Best Practices- XSD * minOccurs and maxOccurs inside choice(Oct 14 '13) * XML Schema - maxOccurs within choice element(Nov 8 '13) XML Schema samples * schema for XML Schema * schema for XSLT 2.0 stylesheets * DocBook V5.0 W3C XML Schema * DocBook V4.5 W3C XML Schema * Spring XML Beans Schema, version 3.0 * ONVIF Schema * oneM2M Release 1 Schemas RELAX NG * RELAX NG home page * RELAX NG Specification * RELAX NG Compact Syntax * RELAX NG Compact Syntax Tutorial * 'RELAX NG'(Book written by Eric van der Vlist) * RELAX NG Samples ** DocBook V5.0 RELAX NG ** DocBook V4.5 RELAX NG Schematron * Schematron specification final committee draft * Schematron reference * [http://www.data2type.de/en/xml-xslt-xslfo/schematron/schematron-introduction/ Schematron introduction] * [http://www.xml.com/lpt/a/1318 An Introduction to Schematron](November 12, 2003) * ISO Schematron tutorial * [http://www.ibm.com/developerworks/library/x-stron/ Discover the flexibility of Schematron abstract patterns](08 October 2004) * Combining Schematron with other XML Schema languages(2010) * Combining Schematron with W3C XML Schema Validation(MSDN, September 2004) Web Services Notification * Web Services Notification : a set of specifications that standardise the way Web services interact using "Notifications" or "Events". * OASIS Web Services Notification (WSN) TC * WS-BaseNotification 1.3 ** Specification ** XML Schema ** WSDL * WS-BrokeredNotification 1.3 ** Specification ** XML Schema ** WSDL * WS-Topics 1.3 ** Specification ** XML Schema DocBook * "DocBook 5.1: The Definitive Guide" by Norman Walsh * "DocBook: The Definitive Guide" by Norman Walsh and Leonard Muellner * "DocBook XSL: The Complete Guide 4th Edition" by Bob Stayton * DocBook XSL Stylesheets: Reference Documentation * Docbook FAQ Dublin Core Metadata * Dublin Core at Wikipedia ** The Dublin Core Schema is a small set of vocabulary terms that can be used to describe web resources (video, images, web pages, etc.), as well as physical resources such as books or CDs, and objects like artworks. * DCMI Metadata Terms * Dublin Core Metadata Element Set, Version 1.1 * Dublin Core User Guide * Guidelines for implementing Dublin Core in XML * Expressing Dublin Core metadata using HTML/XHTML meta and link elements * Simple Dublin Core ** An XML Encoding of Simple Dublin Core Metadata ** Simple Dublin Core XML Schema GraphML * GraphML Primer * GraphML Specification * Comparison between XML to SVG Transformation Mechanisms WADL * WADL(Web Application Description Language) : a XML description of a deployed RESTful web application. * WADL Specification * java.net WADL project XAML * XAML(eXtensible Application Markup Language) : a declarative XML-based language developed by Microsoft that is used for initializing structured values and objects. * XAML * Markup Extensions for XAML Overview * Markup Extensions and WPF XAML (.NET Framework 4) Tips and Tricks Java and XML Identifying the implementation of JAXP in use System.out.printf("%1$s = %2$s\n", "javax.xml.parsers.SAXParserFactory", System.getProperty("javax.xml.parsers.SAXParserFactory")); System.out.printf("%1$s = %2$s\n", "javax.xml.parsers.DocumentBuilderFactory", System.getProperty("javax.xml.parsers.DocumentBuilderFactory")); System.out.printf("%1$s = %2$s\n", "javax.xml.transform.TransformerFactory", System.getProperty("javax.xml.transform.TransformerFactory")); System.out.printf("%1$s = %2$s\n", "javax.xml.xpath.XPathFactory", System.getProperty("javax.xml.xpath.XPathFactory")); System.out.printf("%1$s = %2$s\n", "javax.xml.validation.SchemaFactory", System.getProperty("javax.xml.validation.SchemaFactory")); System.out.printf("SaxParserFactory implementation = %1$s\n", SAXParserFactory.newInstance().getClass().getName()); System.out.printf("DocumentBuilderFactory implementation = %1$s\n", DocumentBuilderFactory.newInstance().getClass().getName()); System.out.printf("TransformerFactory implementation = %1$s\n", TransformerFactory.newInstance().getClass().getName()); System.out.printf("XPathFactory implementation = %1$s\n", XPathFactory.newInstance().getClass().getName()); System.out.printf("SchemaFactory implementation = %1$s\n", SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).getClass().getName()); Combining schema and validation * org.apache.oozie.service.SchemaService.java XQuery Applying aggregation functions on XQuery's query When using the aggregation function such as count with for clause, apply the function to the entire for clause, not return. The following query returns 10 lines of 1. for $x in (1 to 10) return count($x) Maybe, if you want 10, the following query will be right. count(for $x in (1 to 10) return ($x)) Other functions for sequence, such as index-of or distinct-values can be used in the same way. Useful or intelligent expressions of XQuery Think over the following expressions. What are they? These are from the book "XSLT Coookbook" by Sal Mangano. (50,45,40,34,32,29,-1)'XL', 'L', 'M', 'S', 'XS')), size), 7)[1] The following iterates just n times not n2 times. for $pos in 1 to count($sequence), $item in $sequence$pos return $item , $pos Use positional variable with order by Positional variables are calculated before oder by process. If you want to use positional variables after ordering, you can make additional query with positional variables on ordered query like inline query of SQL. for $y at $i in (for $x in $doc//@id order by string($x) return $x) return {string($y)} Applying XQuery on HTML Saxon can't parse HTML file directly. But using TagSoup along with Saxon, you can parse HTML and apply XPath or XQuery to access data. The sample below shows the overall programming. package thirdstage.exercise.xml.saxon; import java.io.File; import java.io.FileInputStream; import java.net.URL; import javax.xml.parsers.DocumentBuilder; import javax.xml.transform.Source; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.sax.SAXSource; import net.sf.saxon.Configuration; import net.sf.saxon.dom.DocumentBuilderImpl; import net.sf.saxon.lib.ParseOptions; import net.sf.saxon.lib.Validation; import net.sf.saxon.s9api.Processor; import net.sf.saxon.s9api.XQueryCompiler; import net.sf.saxon.s9api.XQueryEvaluator; import net.sf.saxon.s9api.XQueryExecutable; import net.sf.saxon.s9api.XdmNode; import net.sf.saxon.s9api.XdmValue; import org.ccil.cowan.tagsoup.Parser; import org.testng.annotations.Test; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.XMLReader; ... @Test public void testXqueryOnHtmlAlongWithTagSoup() throws Exception{ Configuration cfg = new Configuration(); cfg.setSchemaValidationMode(Validation.LAX); cfg.setValidation(false); cfg.setValidationWarnings(true); Processor proc = new Processor(cfg); URL url = ClassLoader.getSystemResource("thirdstage/exercise/xml/saxon/krx-stock-code-only-10.html"); XMLReader xr = new org.ccil.cowan.tagsoup.Parser(); //xr.setFeature(Parser.namespacesFeature, false); Source src = new SAXSource(xr, new InputSource(new FileInputStream(new File(url.toURI())))); net.sf.saxon.s9api.DocumentBuilder db = proc.newDocumentBuilder(); XdmNode input = db.build(src); String qr = new StringBuilder() .append("declare default element namespace \"http://www.w3.org/1999/xhtml\";\n") .append("for $x in /html/body1/table1/tr/td1/child::text() return $x").toString(); XQueryCompiler xqc = proc.newXQueryCompiler(); XQueryExecutable xqe = xqc.compile(qr); XQueryEvaluator xqev = xqe.load(); xqev.setSource(input.asSource()); XdmValue result = xqev.evaluate(); System.out.printf("The result of query contains %1$d items.\n", result.size()); System.out.printf(result.toString()); } ...